package view.collection.heap;

import javax.swing.BoxLayout;
import javax.swing.JScrollPane;

import view.common.InteractivelyControlled;
import controller.HeapController;

/**
 *
 */
public class HeapPanel<T> extends javax.swing.JPanel implements
		InteractivelyControlled {

	private static final long serialVersionUID = -4699806047069257635L;

	private HeapView<T> view;

	private HeapController<Integer> controller;

	public HeapPanel(HeapView<T> view) {
		this.view = view;
		initComponents();
	}

	public void addController(HeapController<Integer> controller) {
		this.controller = controller;
		this.view.addController(controller);
		this.buttonsPanel.addController(controller);
	}

	public HeapView<T> getView() {
		return view;
	}

	public HeapButtonsPanel getButtonsPanel() {
		return buttonsPanel;
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {
		buttonsPanel = new HeapButtonsPanel();
		setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
		add(buttonsPanel);
		add(new JScrollPane(view));
	}// </editor-fold>//GEN-END:initComponents

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private HeapButtonsPanel buttonsPanel;

	// End of variables declaration//GEN-END:variables

	@Override
	public HeapController<Integer> getController() {
		return controller;
	}
}
